package pt.isel.lercm.projectmanager.managedController.generic;

import java.io.IOException;

import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;


public abstract class GenericManagedBean {

	public abstract void init();
	
	public void redirectToPage(String path, boolean withMessage){
		try {
			ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
			
			if (withMessage){
				context.getFlash().setKeepMessages(true);
			}
			
			context.redirect(context.getRequestContextPath() + path);
		} catch (IOException e) {
			throw new FacesException(e);
		}
	}
}
